<template>
    <div class="container">
      <div class="move_box">
        <div class="banner">
          <p><span>多样化、个性化</span><br/>产品服务</p>
        </div>
        <div class="download_item_box">
          <div class="download_item" v-for="(item, index) in form.urlList" :key="index">
            <div>
              <img src="../../assets/Microsoft.png" alt="">
            </div>
            <div>
              <span>{{item.title}}</span>
            </div>
            <div>
              <el-button plain @click="handleShowLogs(item,index)">更新日志<i class="el-icon-arrow-right el-icon--right"></i></el-button>
              <el-button plain @click="handleMoveDownload">下载软件<i class="el-icon-download el-icon--right"></i></el-button>
            </div>
          </div>
        </div>

        <div class="footer">
          <div>
            <p>关于OpenGADL</p>
            <div class="overflow">OpenGADL是由重庆大学周喜川教授团队基于多年研发成果打造的产品，构建了开源、开放的自动化深度学习工具软硬件体系，致力于打造赋能千行百业的通用智能计算平台。</div>
          </div>
          <div class="">
            <p>开发资源</p>
            <p class="point">OpenGADL社区<i class="el-icon-right pl6"></i></p>
            <p class="point" @click="handleToDocument">文档中心<i class="el-icon-right pl6"></i></p>
          </div>
          <div class="">
            <p>联系我们</p>
            <p><i class="el-icon-message"></i> 联系邮箱：isbi@cqu.edu.cn</p>
            <p><i class="el-icon-phone-outline"></i> 客服电话：18696936613</p>
          </div>
        </div>

        <el-drawer
          title="更新日志"
          :visible.sync="drawer"
          direction="rtl"
          size="70%"
          >
          <div class="logs_box">
            <div class="logs_item" v-for="(item,index) in logList" :key="index">
              <div class="logs_head">
                <div><span>{{ item.versions }}</span></div>
                <div><span>{{ item.uploadTime }}</span></div>
              </div>
              <div class="logs_contet">
                <span>{{ item.logtext }}</span>
              </div>
            </div>
          </div>
        </el-drawer>
      </div>
      <div class="pc_box">
        <div class="head_bg">
          <h3><span>多样化、个性化</span> 产品服务</h3>
        </div>
        <div class="box">

          <div class="software">
            <div class="software_item" :class="index == activeIndex?'active':''" v-for="(item, index) in form.urlList" :key="index" @click="handleItem(item,index)">
              <div>
                <img src="../../assets/Microsoft.png" alt="">
              </div>
              <div>
                <span>{{item.title}}</span>
              </div>
              <div>
                <el-button plain @click.stop="handleDownloadPc(item)">下载客户端<i class="el-icon-download el-icon--right"></i></el-button>
              </div>
            </div>
          </div>
  
          <div class="logs">
            <div class="log_item" v-for="(item,index) in logList" :key="index">
              <div class="version"><span>{{ item.versions }}</span></div>
              <p>{{ item.logtext }}</p>
              <div class="date">{{ item.uploadTime }}</div>
            </div>
          </div>
        </div>

        <div class="footer" id="footer">
          <div>
            <p>{{ $store.state.footerData[2]?.title }}</p>
            <div class="overflow">{{ $store.state.footerData[2]?.subtitle }}</div>
          </div>
          <div class="">
            <p>{{ $store.state.footerData[0]?.title }}</p>
            <p class="point">OpenGADL社区<i class="el-icon-right pl6"></i></p>
            <p class="point" @click="handleToDocument">文档中心<i class="el-icon-right pl6"></i></p>
          </div>
          <div class="">
            <p>{{ $store.state.footerData[1]?.title }}</p>
            <p><i class="el-icon-message"></i> 联系邮箱：{{ $store.state.footerData[1]?.email }}</p>
            <p><i class="el-icon-phone-outline"></i> 客服电话：{{ $store.state.footerData[1]?.phone }}</p>
          </div>
        </div>
      </div>

      <el-dialog
        title="下载提示"
        :visible.sync="dialogVisible"
        width="30%"
        >
        <div class="downloadHref">下载链接: <a @click="handleDownload">{{src}}</a></div>
        <div>提取码: {{ code }}</div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">关闭</el-button>
        </span>
</el-dialog>
    </div>
  </template>
  <script>
    export default {
      name: "web_content",
      components: {
      },
      data() {
        return {
          form:{},
          drawer:false,
          dialogVisible:false,
          src:'',
          code:'',
          activeIndex:0,
          logList:[],
        };
      },
      props: {},
      mounted() {
        this.getData()
      },
      methods: {
        handleToDocument(){
        this.$store.commit('navIndexCount',2)
        this.$router.push('/documention')
    },

    getData(){
      this.$api.GetListByType(8).then((res)=>{
        this.form = res[0]
        this.logList = res[0].urlList[0].appList
        console.log(this.logList)
      })
    },

    handleItem(item,index){
      this.activeIndex = index
      this.logList = item.appList
    },

    handleDownloadPc(item){
      this.dialogVisible = true
      this.src = item.subtitle 
      this.code = item.name 
    },

    handleShowLogs(item,index){
      this.logList = item.appList
      this.drawer = true
    },

    handleDownload(){
      window.open(this.src)
      
      // console.log(123)
      // const elink = document.createElement("a");
      // elink.download = 'OpenGADL Model.exe'; //下载文件名称,
      // elink.style.display = "none";
      // elink.href = './OpenGADL Model.exe'
      // document.body.appendChild(elink);
      // elink.click();
      // document.body.removeChild(elink);
    },

    handleMoveDownload(){
      this.$message({
          message: '请前往电脑端下载！',
          center: true,
          type:'warning',
          offset:70
        });
      }
      },
    };
  </script>
  <style lang="scss" scoped>

  .active{
    border: 1px solid #1757d5;
  }

  .move_box,.pc_box{
    display:none;
  }

  ::v-deep .el-drawer__header{
      font-size: 17px;
  }

  @media screen and (max-width: 750px) {
    .container{
      margin-top: 60px;
      width:100%;
    }

    .logs_box{
      height: 100%;
      overflow-y: auto;
      .logs_item{
        padding: 12px 8px;
        opacity: 1;
        background: rgba(255, 255, 255, 1);
        box-shadow: 0px 0px 5px  rgba(0, 0, 0, 0.1);
        .logs_head{
          display: flex;
          justify-content: space-between;
          align-items: center;
        }
        .logs_head>div:first-child{
          width: 52px;
          height: 24px;
          display: flex;
          align-items: center;
          justify-content: center;
          opacity: 1;
          border-radius: 20px;
          background: rgba(51, 51, 51, 1);
          span{
            color: #fff;
            font-size: 11px;
          }
        }
  
        .logs_head>div:last-child{
          margin-right: 8px;
          font-size: 14px;
          color: rgba(153, 153, 153, 1);
        }
  
        .logs_contet{
          margin-top: 12px;
          font-size: 14px;
          font-weight: 400;
          letter-spacing: 0px;
          line-height: 24px;
          color: rgba(51, 51, 51, 1);
          overflow: hidden;
        }
      }
    }

    .move_box{
      display:block;
      .banner{
        display: flex;
        align-items: center;
        justify-content: center;
        height: 200px;
        background-image: url('../../assets/head_bg_move.png');
        background-repeat: no-repeat;
        background-size: cover;
        p{
          text-align: center;
          font-size:24px;
          font-weight:700;
          span{
            font-size:24px;
            font-weight:700;
            color: rgba(102, 8, 116, 1);
            line-height: 50px;
          }
        }
        
      }
      .download_item_box{
        margin-top: -30px;
        .download_item{
          margin: 0 auto;
          margin-bottom: 10px;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          height: 160px;
          width: 95%;
          opacity: 1;
          background: rgba(255, 255, 255, 1);
          box-shadow: 0px 0px 5px  rgba(0, 0, 0, 0.1);
          div{
            span{
              font-size: 20px;
              font-weight: 700;
              letter-spacing: 0px;
              line-height: 54px;
              color: rgba(51, 51, 51, 1);
            }
          }
        }
      }

      .footer{
        padding:16px;
        background-image:-webkit-linear-gradient( -180deg, rgb(42,39,167) 0%, rgb(130,48,142) 100%);
        .overflow{
          width: 345px;
          display: -webkit-box;
          -webkit-line-clamp: 4;
          -webkit-box-orient: vertical;
          overflow: hidden;
          text-overflow: ellipsis;
          line-height:30px;
          color: rgba(181, 181, 181, 1);
          font-size: 14px;
          }
      }
      .footer>div{
        margin-bottom:20px;
      }
      .footer>div>p{
        text-align: left;
        margin-bottom: 16px;
        color: rgba(181, 181, 181, 1);
        font-size: 14px;
        }
        .footer>div>p:first-child{
        font-size: 18px;
        color: rgba(217, 217, 217, 1);
        }
    }
  }

  @media screen and (min-width: 750px) {
    .pc_box{
      display:block;
    }

    .downloadHref{
      margin-bottom:10px;
      a{
        color:#1757d5;
        text-decoration:underline
      }
      a:hover{
        
        cursor:pointer;
      }
      
    }

    .head_bg{
      display: flex;
      justify-content: center;
      margin-top: 70px;
      height: 300px;
      background-image: url('../../assets/download-bg.png');
      background-repeat: no-repeat;
      background-size: cover;
      h3{
        margin-top: 60px;
        font-size: 40px;
        font-weight: 700;
        span{
          color: rgba(102, 8, 116, 1)
        }
      }
  
    }
    .box{
      margin: 0 auto;
      margin-top: -120px;
      width: 1200px;
      .software{
        display: flex;
        justify-content: center;
        .software_item{
          margin-right: 40px;
          width: 360px;
          height: 200px;
          opacity: 1;
          background: rgba(255, 255, 255, 1);
          box-shadow: 0px 0px 5px  rgba(0, 0, 0, 0.1);
          div{
            display: flex;
            align-items: center;
            justify-content: center;
            height: 54px;
            span{
              font-size: 24px;
              font-weight: 700;
              letter-spacing: 0px;
              line-height: 54px;
              color: rgba(51, 51, 51, 1);
            }
          }
          div:first-child{
            margin-top: 18px;
          }
        }
        .software_item:last-child{
          margin-right: 0;
        }
      }
  
      .logs{
        padding: 0 16px;
        margin-top: 43px;
        height: 280px;
        overflow-y: auto;
        .log_item{
          position: relative;
          padding-left: 30px;
          margin-bottom: 20px;
          display: flex;
          align-items: center;
          height: 70px;
          opacity: 1;
          border: 1px solid rgba(235, 235, 235, 1);
  
          .version{
            margin-right: 14px;
            width: 70px;
            height: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 13px;
            opacity: 1;
            border-radius: 20px;
            background: rgba(51, 51, 51, 1);
            span{
              color: #fff;
            }
          }
  
          p{
            width: 600px;
            font-size: 16px;
            font-weight: 400;
            color: rgba(51, 51, 51, 1);
          }

          .date{
            font-size: 15px;
            position: absolute;
            right: 12px;
          }
        }
      }
    }
    .footer{
      padding: 50px 200px;
      display: flex;
      justify-content: center;
      height: 150px;
      background-color: #000;
      background-image:-webkit-linear-gradient( -180deg, rgb(42,39,167) 0%, rgb(130,48,142) 100%);
    }
    
    .footer>div:first-child{
      margin-right: 120px;
      width: 400px;
    }
    
    .overflow{
      width: 400px;
      display: -webkit-box;
      -webkit-line-clamp: 4;
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
      color: rgba(163, 158, 158, 1);
      font-size: 16px;
    }
    
    .footer>div:not(.footer>div:first){
      width: 250px;
    }
    .footer>div:last-child{
      margin-left: 80px;
    }
    .footer>div>p{
      text-align: left;
      margin-bottom: 26px;
      color: rgba(163, 158, 158, 1);
      font-size: 16px;
    }
    .footer>div>p:first-child{
      font-size: 20px;
      color: #fff;
    }
  }
 
  .container{
    overflow-y: auto;
    width:100%;
  }

  
  </style>